<template>
	<!-- 用户下拉框组件 -->
	<v-combobox v-model="currentSelectUser" :items="selectUserItems" :label="selectUserCommentModel.label"
		:return-object="selectUserCommentModel.isReturnObj" @input="userSelectEvent" dense outlined chips>
	</v-combobox>
</template>

<script>
	export default {
			name: 'UserSelect',
			props: {
				callBack: {
					type: Function, //参数类型：函数
				},
				selectUserCommentModel: {
					loadSelectUserItemsUrl: '',
					isReturnObj:false,
					label:'选择用户',
					paramterUserList:[]
				},
			},
			data: () => ({
				selectUserItems: [],
				currentSelectUser: null
			}),
			watch: {
				selectUserCommentModel: {
					handler(newVal) {
						this.$emit('update:selectUserCommentModel', newVal)
						
						this.loadUserItems()
					},
					deep: true
				},
			},
					
			methods: {
				async loadUserItems() {
					if(this.selectUserCommentModel.paramterUserList!=null && this.selectUserCommentModel.paramterUserList.length>0){
							this.selectUserItems =this.selectUserCommentModel.paramterUserList;
							return
					}
					
					var response = await this.$httpRequest({
						url: this.selectUserCommentModel.loadSelectUserItemsUrl,
						method: 'get',
					})
	
					if (response.status == 1) {
						this.selectUserItems = response.data
					} else {
						this.$message.error(response.info)
					}
				},
				userSelectEvent(item) {
					this.$props.callBack(item)
				},
	
			}
		}
	
</script>

